<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/templates/template.xhtml">
            <ui:define name="content">
            <b><h3><h:outputLabel value="Legg til ny bruker" rendered="#{user.findRole()}"/></h3></b>
            <b><h3><h:outputLabel value="Denne siden har du ikke tilgang til!" rendered="#{not user.findRole()}"/></h3></b>
            <br/>
            <h:form>
                <h:commandLink  action="../protected/userAdministration.xhtml" rendered="#{user.findRole()}">Tilbake</h:commandLink>
            </h:form>
            <br/><br/>
            <h:form>
                <h:outputLabel style="color: green" value="Brukeren er lagt til" rendered="#{user.checkUserAdded}"/>
                <h:panelGrid columns="2" rendered="#{user.findRole()}">
                    <h:outputText value="Brukernavn:" rendered="#{user.findRole()}" />
                    <h:inputText value="#{user.newUser.username}" rendered="#{user.findRole()}">
                    <f:validateLength minimum="1"/>
                </h:inputText>
                    <h:outputText value="Navn:" rendered="#{user.findRole()}"/>
                    <h:inputText value="#{user.newUser.name}" rendered="#{user.findRole()}">
                    <f:validateLength minimum="1"/>
                </h:inputText>
                    <h:outputText value="Passord:" rendered="#{user.findRole()}"/>
                    <h:inputText value="#{user.newUser.password}" rendered="#{user.findRole()}">
                    <f:validateLength minimum="1"/>
                </h:inputText>
                    <h:outputText value="Rolle" rendered="#{user.findRole()}"/>
                    <h:selectOneMenu value="#{user.newUser.role}" rendered="#{user.findRole()}">
                        <f:selectItem itemLabel="elev" itemValue="bruker"/>
                        <f:selectItem itemLabel="Lerer" itemValue="system"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:commandButton value="Lagre" action="#{user.addNewUser(user.newUser)}" rendered="#{user.findRole()}"/>
                </h:form>
        </ui:define>
        </ui:composition>
    </h:body>
</html>